package cs3343.project.family.testing;

import static org.junit.Assert.assertEquals;

import javax.swing.JComboBox;
import javax.swing.JOptionPane;

import org.junit.Test;

import cs3343.project.family.*;
import cs3343.project.family.UI.*;

/**
 * The Class ProfileTest.
 */
public class ProfileTest {

	/* Test whether select one player can start game
	 * Case: Select 1 player, first two with option 5(i.e Sis)
	 * Result: message warning pop out
	*/
	/**
	 * At least two.
	 */
	@Test
	public void atLeastTwo() {

		int numPlayer=0;
		boolean result;
		
		ConfigManager.loadLangFile();
		GameController gc=new GameController();
		CharacterFrame cF= new CharacterFrame(gc);
		
		JComboBox[] combo=cF.getComboList();
		combo[0].setSelectedIndex(5);
		
		// try to start the game after select one character
		cF.getBtn_startGame().doClick();
		
		int resultOption = JOptionPane.showConfirmDialog(null, "A warning of (Please select at least 2 characters) had pop out", "Test Case Result",
		        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);

		assertEquals(resultOption, JOptionPane.YES_OPTION);
	}
	
	/* Test whether having same name player can start game
	 * Case: Select 4 player, first two with option 4(i.e Bro) and option 3(i.e 中文) name
	 * 		 last two for option2(i.e Tester)
	 * Result: message warning pop out
	*/
	
	/**
	 * Same name.
	 */
	@Test
	public void sameName(){
		ConfigManager.loadLangFile();
		GameController gc=new GameController();
		CharacterFrame cF= new CharacterFrame(gc);
		
		// select 4 person, last two at same name
		// not same name
		JComboBox[] combo=cF.getComboList();
		combo[0].setSelectedIndex(4);
		combo[1].setSelectedIndex(3);
		// same name
		combo[2].setSelectedIndex(2);
		combo[3].setSelectedIndex(2);
		
		// try to start the game
		cF.getBtn_startGame().doClick();
		
		int resultOption = JOptionPane.showConfirmDialog(null, "A warning of (Please do not select same character twice) had pop out", "Test Case Result",
		        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);

		assertEquals(resultOption, JOptionPane.YES_OPTION);
		
	}

}
